{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "        gpa         gre  actual_label\n",
      "0  3.177277  594.102992             0\n",
      "1  3.412655  631.528607             0\n",
      "2  2.728097  553.714399             0\n",
      "3  3.093559  551.089985             0\n",
      "4  3.141923  537.184894             0\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "\n",
    "admissions = pd.read_csv(\"admissions.csv\")\n",
    "admissions[\"actual_label\"] = admissions[\"admit\"]\n",
    "admissions = admissions.drop(\"admit\", axis=1)\n",
    "\n",
    "print(admissions.head())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "          gpa         gre  actual_label\n",
      "260  3.414036  577.665610             0\n",
      "173  2.932147  564.798764             0\n",
      "256  2.674040  599.895858             0\n",
      "167  2.923581  622.524665             0\n",
      "400  3.414376  704.934217             1\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "np.random.seed(8)\n",
    "admissions = pd.read_csv(\"admissions.csv\")\n",
    "admissions[\"actual_label\"] = admissions[\"admit\"]\n",
    "admissions = admissions.drop(\"admit\", axis=1)\n",
    "shuffled_index = np.random.permutation(admissions.index)\n",
    "#print shuffled_index\n",
    "shuffled_admissions = admissions.loc[shuffled_index]\n",
    "\n",
    "train = shuffled_admissions.iloc[0:515]\n",
    "test = shuffled_admissions.iloc[515:len(shuffled_admissions)]\n",
    "\n",
    "print(shuffled_admissions.head())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.674418604651\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "e:\\python27\\lib\\site-packages\\ipykernel\\__main__.py:9: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n"
     ]
    }
   ],
   "source": [
    "shuffled_index = np.random.permutation(admissions.index)\n",
    "shuffled_admissions = admissions.loc[shuffled_index]\n",
    "train = shuffled_admissions.iloc[0:515]\n",
    "test = shuffled_admissions.iloc[515:len(shuffled_admissions)]\n",
    "model = LogisticRegression()\n",
    "model.fit(train[[\"gpa\"]], train[\"actual_label\"])\n",
    "\n",
    "labels = model.predict(test[[\"gpa\"]])\n",
    "test[\"predicted_label\"] = labels\n",
    "\n",
    "matches = test[\"predicted_label\"] == test[\"actual_label\"]\n",
    "correct_predictions = test[matches]\n",
    "accuracy = len(correct_predictions) / float(len(test))\n",
    "print(accuracy)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0833333333333\n",
      "1.0\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "e:\\python27\\lib\\site-packages\\ipykernel\\__main__.py:4: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n"
     ]
    }
   ],
   "source": [
    "model = LogisticRegression()\n",
    "model.fit(train[[\"gpa\"]], train[\"actual_label\"])\n",
    "labels = model.predict(test[[\"gpa\"]])\n",
    "test[\"predicted_label\"] = labels\n",
    "matches = test[\"predicted_label\"] == test[\"actual_label\"]\n",
    "correct_predictions = test[matches]\n",
    "accuracy = len(correct_predictions) / len(test)\n",
    "true_positive_filter = (test[\"predicted_label\"] == 1) & (test[\"actual_label\"] == 1)\n",
    "true_positives = len(test[true_positive_filter])\n",
    "false_negative_filter = (test[\"predicted_label\"] == 0) & (test[\"actual_label\"] == 1)\n",
    "false_negatives = len(test[false_negative_filter])\n",
    "\n",
    "sensitivity = true_positives / float((true_positives + false_negatives))\n",
    "print(sensitivity)\n",
    "\n",
    "false_positive_filter = (test[\"predicted_label\"] == 1) & (test[\"actual_label\"] == 0)\n",
    "false_positives = len(test[false_positive_filter])\n",
    "true_negative_filter = (test[\"predicted_label\"] == 0) & (test[\"actual_label\"] == 0)\n",
    "true_negatives = len(test[true_negative_filter])\n",
    "\n",
    "specificity = (true_negatives) / float((false_positives + true_negatives))\n",
    "print(specificity)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0.5609843   0.54353013  0.53738758  0.51726798  0.51293244  0.50963682\n",
      "  0.50805118  0.5013659   0.49677188  0.47092118  0.46944138  0.458001\n",
      "  0.45602026  0.4542968   0.44389899  0.4402378   0.42876635  0.42750536\n",
      "  0.41991909  0.41941691  0.41661827  0.41044096  0.39681722  0.39640822\n",
      "  0.39416904  0.3924445   0.39239017  0.39157132  0.38512237  0.38084774\n",
      "  0.38066394  0.37582053  0.37301107  0.37157822  0.3631628   0.36181317\n",
      "  0.35714697  0.35559634  0.35559185  0.35537882  0.33709727  0.33689433\n",
      "  0.33008375  0.32675034  0.30176359  0.29714575  0.24119331]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgsAAAFkCAYAAACuFXjcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAPYQAAD2EBqD+naQAAGLlJREFUeJzt3X+M5XV97/Hnmx+VYse5sdvsaroJkOyuY5uiM9pAqN42\nVLZgNBqxOEDlLl4bLvT23ultbZOWoJhKtIUNNlCwertLVidi/1r7awnU3tsI+GOm0DZ3gAmFNqis\nYNthF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4T4JAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x8596e10>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from sklearn import metrics\n",
    "\n",
    "probabilities = model.predict_proba(test[[\"gpa\"]])\n",
    "fpr, tpr, thresholds = metrics.roc_curve(test[\"actual_label\"], probabilities[:,1])\n",
    "print thresholds\n",
    "plt.plot(fpr, tpr)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.721069019201\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import roc_auc_score\n",
    "probabilities = model.predict_proba(test[[\"gpa\"]])\n",
    "\n",
    "# Means we can just use roc_auc_curve() instead of metrics.roc_auc_curve()\n",
    "auc_score = roc_auc_score(test[\"actual_label\"], probabilities[:,1])\n",
    "print(auc_score)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
